﻿// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

var editor = new TextEditor();
var history = new History();

// 输入内容并保存快照
editor.Type("Hello");
history.Push(editor.CreateMemento());

editor.Type(" World");
history.Push(editor.CreateMemento());

editor.Type("!");
Console.WriteLine("当前内容: " + editor); // Hello World!

// 撤销一次
if (history.HasHistory)
{
  editor.Restore(history.Pop());
  Console.WriteLine("撤销后: " + editor); // Hello World
}

// 再撤销一次
if (history.HasHistory)
{
  editor.Restore(history.Pop());
  Console.WriteLine("再撤销: " + editor); // Hello
}